{% extends 'generic/object.html' %}
{% load buttons %}
{% load helpers %}
{% load static %}
{% load plugins %}

{% block breadcrumbs %}
  <li><a href="{% url 'secrets:secret_list' %}">Secrets</a></li>
  <li><a href="{% url 'secrets:secret_list' %}?role_id={{ object.role.pk }}">{{ object.role }}</a></li>
  <li><a href="{{ object.assigned_object.get_absolute_url }}">{{ object.assigned_object }}</a></li>
  <li>{{ object }}</li>
{% endblock %}

{% block buttons %}
  {% if perms.secrets.change_secret %}
    {% edit_button object %}
  {% endif %}
  {% if perms.secrets.delete_secret %}
    {% delete_button object %}
  {% endif %}
{% endblock %}

{% block content %}
<div class="row">
	<div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Secret Attributes</strong>
            </div>
            <table class="table table-hover panel-body">
                <tr>
                    <td>Assigned object</td>
                    <td>
                        <a href="{{ object.assigned_object.get_absolute_url }}">{{ object.assigned_object }}</a>
                    </td>
                </tr>
                <tr>
                    <td>Role</td>
                    <td>
                      <a href="{{ object.role.get_absolute_url }}">{{ object.role }}</a>
                    </td>
                </tr>
                <tr>
                    <td>Name</td>
                    <td>{{ object.name|placeholder }}</td>
                </tr>
            </table>
        </div>
        {% include 'inc/custom_fields_panel.html' %}
        {% plugin_left_page object %}
	</div>
	<div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Secret Data</strong>
            </div>
            <div class="panel-body">
                <form id="secret_form">
                    {% csrf_token %}
                </form>
                <div class="row">
                    <div class="col-md-2">Secret</div>
                    <div class="col-md-6" id="secret_{{ object.pk }}">********</div>
                    <div class="col-md-4 text-right noprint">
                        <button class="btn btn-xs btn-success unlock-secret" secret-id="{{ object.pk }}">
                            <i class="mdi mdi-lock"></i> Unlock
                        </button>
                        <button class="btn btn-xs btn-default copy-secret collapse" secret-id="{{ object.pk }}" data-clipboard-target="#secret_{{ object.pk }}">
                            <i class="mdi mdi-content-copy"></i> Copy
                        </button>
                        <button class="btn btn-xs btn-danger lock-secret collapse" secret-id="{{ object.pk }}">
                            <i class="mdi mdi-lock-open"></i> Lock
                        </button>
                    </div>
                </div>
            </div>
        </div>
        {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='secrets:secret_list' %}
        {% plugin_right_page object %}
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        {% plugin_full_width_page object %}
    </div>
</div>

{% include 'secrets/inc/private_key_modal.html' %}
{% endblock %}

{% block javascript %}
<script src="{% static 'js/secrets.js' %}?v{{ settings.VERSION }}"></script>
{% endblock %}
